//
//  MCTopUpRecordViewController.m
//  TLYL
//
//  Created by miaocai on 2017/7/10.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCTopUpRecordViewController.h"
#import "MCTopUpRecrdTableViewCell.h"
#import "MCTopUpRecordModel.h"
#import "MCTopUpRecDetailViewController.h"

@interface MCTopUpRecordViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,weak) UITableView *tableView;
@property (nonatomic,strong) NSMutableArray *tableViewDataArray;
@end

@implementation MCTopUpRecordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"充值记录";
    [self addNavRightBtn];
    [self setUpUI];
    [self loadDataAndShow];
    
}

- (void)addNavRightBtn {
    
    UIButton *btn = [[UIButton alloc] init];
    [btn setImage:[UIImage imageNamed:@"kefu"] forState:UIControlStateNormal];
    [btn setTitle:@"全部" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    btn.titleLabel.font = [UIFont systemFontOfSize:14.0f];
    btn.frame = CGRectMake(0, 0, MC_REALVALUE(44), MC_REALVALUE(44));
    [btn addTarget:self action:@selector(allBtnClick:) forControlEvents:UIControlEventTouchDown];
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    self.navigationItem.rightBarButtonItem = rightItem;
}

- (void)setUpUI{
    
    self.view.backgroundColor = RGB(239, 239, 239);
    /**tabView 创建*/
    UITableView *tab = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, G_SCREENWIDTH, G_SCREENHEIGHT - 64) style:UITableViewStylePlain];
    [self.view addSubview:tab];
    tab.delegate = self;
    tab.dataSource = self;
    self.tableView = tab;
    self.tableView.backgroundColor=RGB(240, 240, 240);
    self.tableView.estimatedRowHeight = MC_REALVALUE(90);
    self.tableView.rowHeight = 100;
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([MCTopUpRecrdTableViewCell class]) bundle:nil] forCellReuseIdentifier:@"MCTopUpRecrdTableViewCell"];
}
- (void)allBtnClick:(UIButton *)btn{
    
  
    
}

- (void)loadDataAndShow{
    for (NSInteger i = 0; i< 10; i++) {
        MCTopUpRecordModel *model = [[MCTopUpRecordModel alloc] init];
        model.money = [NSString stringWithFormat:@"%ld",i+100];
        [self.tableViewDataArray addObject:model];
    }
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.tableViewDataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    MCTopUpRecrdTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MCTopUpRecrdTableViewCell"];
    cell.dataSource = self.tableViewDataArray[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    MCTopUpRecDetailViewController *vc = [[MCTopUpRecDetailViewController alloc] init];
    vc.dataSorce = self.tableViewDataArray[indexPath.row];
    [self.navigationController pushViewController:vc animated:YES];
}
- (NSMutableArray *)tableViewDataArray{
    if (_tableViewDataArray == nil) {
        _tableViewDataArray = [NSMutableArray array];
    }
    return _tableViewDataArray;
}

@end
